/*
LESS variables are information about icon's compiled state, stored under its original file name

.icon-home {
  width: @icon-home-width;
}

The large array-like variables contain all information about a single icon
@icon-home: x y offset_x offset_y width height total_width total_height image_path name;

At the bottom of this section, we provide information about the spritesheet itself
@spritesheet: width height image @spritesheet-sprites;
*/
@360-name: '360';
@360-x: 0px;
@360-y: 0px;
@360-offset-x: 0px;
@360-offset-y: 0px;
@360-width: 160px;
@360-height: 28px;
@360-total-width: 540px;
@360-total-height: 372px;
@360-image: 'sprite/sprite.png';
@360: 0px 0px 0px 0px 160px 28px 540px 372px 'sprite/sprite.png' '360';
@hao123-name: 'hao123';
@hao123-x: 0px;
@hao123-y: 38px;
@hao123-offset-x: 0px;
@hao123-offset-y: -38px;
@hao123-width: 240px;
@hao123-height: 66px;
@hao123-total-width: 540px;
@hao123-total-height: 372px;
@hao123-image: 'sprite/sprite.png';
@hao123: 0px 38px 0px -38px 240px 66px 540px 372px 'sprite/sprite.png' 'hao123';
@baidu-name: 'baidu';
@baidu-x: 0px;
@baidu-y: 114px;
@baidu-offset-x: 0px;
@baidu-offset-y: -114px;
@baidu-width: 540px;
@baidu-height: 258px;
@baidu-total-width: 540px;
@baidu-total-height: 372px;
@baidu-image: 'sprite/sprite.png';
@baidu: 0px 114px 0px -114px 540px 258px 540px 372px 'sprite/sprite.png' 'baidu';
@spritesheet-width: 540px;
@spritesheet-height: 372px;
@spritesheet-image: 'sprite/sprite.png';
@spritesheet-sprites: @360 @hao123 @baidu;
@spritesheet: 540px 372px 'sprite/sprite.png' @spritesheet-sprites;

/*
The provided classes are intended to be used with the array-like variables

.icon-home {
  .sprite-width(@icon-home);
}
.icon-email {
  .sprite(@icon-email);
}

Example usage in HTML:

`display: block` sprite:
<div class="icon-home"></div>

To change `display` (e.g. `display: inline-block;`), we suggest using a common CSS class:

// CSS
.icon {
  display: inline-block;
}

// HTML
<i class="icon icon-home"></i>
*/
.sprite-width(@sprite) {
  width: extract(@sprite, 5);
}

.sprite-height(@sprite) {
  height: extract(@sprite, 6);
}

.sprite-position(@sprite) {
  @sprite-offset-x: extract(@sprite, 3);
  @sprite-offset-y: extract(@sprite, 4);
  background-position: @sprite-offset-x @sprite-offset-y;
}

.sprite-image(@sprite) {
  @sprite-image: extract(@sprite, 9);
  background-image: e(%('url(%a)', e(@sprite-image)));
}

.sprite(@sprite) {
  .sprite-image(@sprite);
  .sprite-position(@sprite);
  .sprite-width(@sprite);
  .sprite-height(@sprite);
}

/*
The `.sprites` mixin generates identical output to the CSS template
  but can be overridden inside of LESS

This must be run when you have at least 2 sprites.
  If run with a single sprite, then there will be reference errors.

.sprites(@spritesheet-sprites);
*/
.sprites(@sprites, @i: 1) when (@i <= length(@sprites)) {
  @sprite: extract(@sprites, @i);
  @sprite-name: e(extract(@sprite, 10));
  .@{sprite-name} {
    .sprite(@sprite);
  }
  .sprites(@sprites, @i + 1);
}
